#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy  as np
import pandas as pd
import talib as ta

eps = 1e-8

def signal(*args):
    # MtmMax 指标
    df = args[0]
    n = args[1]
    factor_name = args[2]

    df['mtm'] = df['close'] / df['close'].shift(n) - 1
    df['up'] = df['mtm'].rolling(window=n).max().shift(1)
    df[factor_name] = df['mtm'] - df['up']

    return df
